package com.seeyon.apps.ddkk;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.seeyon.apps.ddkk.timer.GetReportTimers;
import com.seeyon.apps.ddkk.timer.NodeDealTimers;
import com.seeyon.apps.kk.manager.KkConfigManager;
import com.seeyon.ctp.common.AbstractSystemInitializer;
import com.seeyon.ctp.common.timer.TimerHolder;
import com.seeyon.kk.utils.ValueUtils;

public class DDKkPluginInitializer extends AbstractSystemInitializer {
	private static Log log = LogFactory.getLog(DDKkPluginInitializer.class);
	private KkConfigManager kkConfigManager;

	public KkConfigManager getKkConfigManager() {
		return kkConfigManager;
	}

	public void setKkConfigManager(KkConfigManager kkConfigManager) {
		this.kkConfigManager = kkConfigManager;
	}

	@Override
	public void initialize() {
		log.info("DD上海区客开插件启动");
		super.initialize();
		// 系统启动的时候 将配置需要的内容 设置到静态变量
		ValueUtils.setConfig(kkConfigManager.createKkConfig());
		Thread autoNode = new Thread(new Runnable() {
			@Override
			public void run() {
				// TODO Auto-generated method stub
				TimerHolder.newTimer(new NodeDealTimers(), new Date(), 5 * 60 * 1000);
				log.info("*****************初始化：	节点自动处理定时任务******************");
			}
    	});
    	autoNode.start();
		Thread report = new Thread(new Runnable() {
			@Override
			public void run() {
				// TODO Auto-generated method stub
				TimerHolder.newTimer(new GetReportTimers(), new Date(), 60 * 60 * 1000);
				log.info("*****************初始化：	获取企业报告定时任务******************");
			}
    	});
    	report.start();
	}

	@Override
	public void destroy() {
		log.info("DD上海区客开插件销毁");
		super.destroy();
	}

}